<template>
  <div>
    <el-table
      :data="durg.result"
      style="width: 100%">
      <el-table-column label="药品图片" prop="drug_cover" width="120px" align="center">
        <template slot-scope="scope">
        <img :src="scope.row.drug_cover" alt="" width="60px" height="40px">
      </template> 
      </el-table-column>
      <el-table-column label="药品名称" prop="drug_name" align="center"></el-table-column>
      <el-table-column label="药品主治" prop="drug_effect" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="药品用法" prop="drug_use" width="120px" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="药品不良反应" prop="drug_bad" width="120px" align="center" show-overflow-tooltip></el-table-column>
      <el-table-column label="药品价格" prop="durg_price" align="center">
        <template slot-scope="scope">
          {{scope.row.durg_price}}元
        </template>
      </el-table-column>
      <el-table-column label="操作" width="180px" align="center">
        <template slot-scope="scope">
          <el-button size="small" type="success" icon="el-icon-check" circle></el-button>
        <el-button size="small" type="info" icon="el-icon-message" circle></el-button>
        <el-button
        @click="$router.push('/home/hospital-update/'+scope.row.h_id)"
        size="small" type="warning" icon="el-icon-edit" circle></el-button>
        <el-button
        @click="deleteItem(scope.row)"
         size="small" type="danger" icon="el-icon-delete" circle></el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
    @current-change="changeCurrentPage"
     style="margin:10px"
     layout="->,total,prev,pager,next,slot,jumper"
     :total="durg.total"
     :page-size="durg.pagesize"
     :current-page="durg.page"
     background></el-pagination>
  </div>
</template>

<script>
import httpApi from '@/http';
  export default {
    data() {
      return {
        durg:{
          page:1, // 当前页码
          pagesize:3, // 每页多少条
          total:0, // 总条目数
          result:[], // 药品数据
        }
      }
    },
    methods: {
      // 查询所有药品
      queryAll(){
        let params = {page:this.durg.page,pagesize:this.durg.pagesize}
        httpApi.durgApi.queryAll(params).then(res =>{
          console.log('药品列表',res);
          this.durg = res.data.data
        })
      },
      changeCurrentPage(page){
      console.log(page);
      this.durg.page = page // 修改当前页
 
      this.queryAll()
      
    },
    },
    mounted(){
      this.queryAll()
    }
  }
</script>

<style lang="scss" scoped>

</style>